package cn.itcast.service.impl;

import cn.itcast.dao.OrderDao;
import cn.itcast.dao.PaylogDao;
import cn.itcast.service.ReportOrderService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service(version = "1.0.0")
public class ReportOrderServiceImpl implements ReportOrderService {

    @Autowired
    private OrderDao orderDao;

    @Autowired
    private PaylogDao paylogDao;


    /**
     * 查询支付数量和预约数量
     * @param date
     * @return
     */
    @Override
    public Map<String, Object> queryPayAndOrderCountByDate(List<String> date) {
           //统计支付数量集合
           List<Integer> payCounts=new ArrayList<>();
           //统计预约数量集合
           List<Integer> orderCounts=new ArrayList<>();
        for (String d : date) {
            //查询指定月份的支付数量以及预约数量
            Integer order = this.orderDao.selectOrderCount(d + "-1", d + "-31");
            orderCounts.add(order);
            Integer pay = this.paylogDao.selectPayCount(d + "-1", d + "-31");
            payCounts.add(pay);
        }

            Map<String,Object> map=new HashMap<>();
            map.put("months",date);
            map.put("payCounts",payCounts);
            map.put("orderCounts",orderCounts);
            return map;


    }
}
